﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace OpenLightGroup.Visualizers.Controls
{
    public class AnimationHelper
    {

        public static DoubleAnimation CreateHeightAnimation
        (UIElement target, double value, Duration animationDuration, bool autoReverse)
        {

            DoubleAnimation animation = new DoubleAnimation();

            animation.AutoReverse = autoReverse;

            animation.To = value;

            animation.Duration = animationDuration;

            Storyboard.SetTarget(animation, target);

            Storyboard.SetTargetProperty(animation, new PropertyPath("(Height)"));

            return animation;

        }

        public static DoubleAnimation CreateOpacityAnimation
            (UIElement target, double value, Duration animationDuration, bool autoReverse)
        {

            DoubleAnimation animation = new DoubleAnimation();

            animation.AutoReverse = autoReverse;

            animation.To = value;

            animation.Duration = animationDuration;

            Storyboard.SetTarget(animation, target);

            Storyboard.SetTargetProperty(animation, new PropertyPath("(Opacity)"));

            return animation;

        }

        public static DoubleAnimation CreateScaleYAnimation
            (UIElement target, double value, Duration animationDuration, bool autoReverse)
        {

            DoubleAnimation animation = new DoubleAnimation();

            animation.AutoReverse = autoReverse;

            animation.To = value;

            animation.Duration = animationDuration;

            Storyboard.SetTarget(animation, target);

            animation.SetValue(Storyboard.TargetPropertyProperty,
                new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"));

            return animation;
        }


        public static DoubleAnimation CreateScaleXAnimation
            (UIElement target, double value, Duration animationDuration, bool autoReverse)
        {

            DoubleAnimation animation = new DoubleAnimation();

            animation.AutoReverse = autoReverse;

            animation.To = value;

            animation.Duration = animationDuration;

            Storyboard.SetTarget(animation, target);

            animation.SetValue(Storyboard.TargetPropertyProperty,
                new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"));

            return animation;


        }
    }
}
